package com.icarsaas.saas.master.repository;

import com.icarsaas.saas.master.model.MasterTenantDetail;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;


@Repository
public interface MasterTenantDetailRepository extends MasterTenantDetailRepositoryCustom, JpaRepository<MasterTenantDetail, String>, JpaSpecificationExecutor<MasterTenantDetail> {
    /**
     * 根据租户主表id查找租户
     * @param masterId 租户主表ID
     * @return
     */
    @Query("select p from MasterTenantDetail p where p.masterTenant.id = :masterId")
    MasterTenantDetail findByMasterId(@Param("masterId") Long masterId);
}

/* 自定义接口
 */
interface MasterTenantDetailRepositoryCustom extends MasterBaseRepository<MasterTenantDetail, String> {

}

@Repository
class MasterTenantDetailRepositoryImpl extends MaterBaseRepositoryImpl<MasterTenantDetail, String> implements MasterTenantDetailRepositoryCustom {

}